<template>
  <div>
    question 从video切换到question页面时，它们二个的生命周期执行先后
    question(beforeCreate)===>question(created)==>question(beforeMount)===>video(beforeDestroy)==>video(destroyed)==>question(mounted)
    <input type="text" />
  </div>
</template>
<script>
export default {
  beforeCreate () {
    // console.log('question beforeCreate')
  },
  created () {
    let arr = [{ id: 1 }, { id: 2 }]
    let all = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
    // 判断all的每一项是否在arr中存在，存在就不要，不存在就要
    const newArr = all.filter(item => {
      // {id:1}===   [{id:1},{id:2}]
      // return 是否存在 存在就不要，不存在就要
      // arr.includes(item)
      // find   findIndex
      const isFind = arr.find(item2 => {
        return item2.id === item.id
      })
      // isFind!=undefined一定是找到了
      return !isFind
    })
    console.log('newArr', newArr)

    // console.log('question created')
  },
  beforeMount () {
    // console.log('question beforeMount')
  },
  mounted () {
    // console.log('question mounted')
  }

  // activated () {
  //   // 缓存组件显示时触发
  //   console.log('question activated')
  // },
  // deactivated () {
  //   // 缓存组件隐藏时触发
  //   console.log('question deactivated')
  // }
}
</script>
<style></style>
